use console::style;

pub fn command_tip(command: &str) {
    message(&format!("Running `{}`", style(command).green()));
}

pub fn multiselect_msg(msg: &str) {
    message(&format!("`{}`", style(msg).green()));
}

pub fn message(msg: &str) {
    println!("[{}] {}", style("f_cli").blue(), msg)
}
pub fn add_dependency_msg(name: &str) {
    message(&format!("新增特性 {}", style(name).yellow()));
}

pub fn update_react_project(name: &str) {
    message(&format!("向React项目中添加 {}", style(name).green()))
}

pub fn command_msg(command: &str) {
    message(&format!("Running `{}`", style(command).yellow()));
}

pub fn add_file_msg(file: &str) {
    message(&format!("Adding {}", style(file).yellow()));
}

pub fn error(msg: &str) {
    message(&format!("{} {}", style("ERROR: ").red(), msg))
}

pub fn exit_error(msg: &str, err: std::io::Error) -> ! {
    error(format!("{msg}: {err:?}").as_str());
    std::process::exit(1);
}

pub fn project_created_msg(project_name: String) {
    message(&format!("{}", style("前端项目已经初始化完毕!").underlined()));

    message("• 开始本地开发!");
    message("  1. 切换到项目目录:");
    message(&format!("     $ {}", style(format!("cd {project_name:#?}")).cyan()));
    message("  2. 按照对应依赖");
    message(&format!("     $ {}", style("npm install 或者 yarn install").cyan()));
    message("  3. 处理husky相关:");
    message(&format!("     $ {}", style("npm run prepare").cyan()));
    message(
        &format!(
            "  该操作可选   $ {}",
            style(
                "npx husky add .husky/pre-commit npx oxlint@latest --fix --quiet  --ignore-path='./src/assets/*'"
            ).cyan()
        )
    );
    message(
        &format!("     $ {}", style("npx husky add .husky/pre-commit 'yarn lint-staged'").cyan())
    );
    message(&format!("     $ {}", style("npx husky add .husky/pre-push 'yarn tsc-test'").cyan()));
    // message(&format!("     $ {}", style("git add .husky/pre-commit").cyan()));
    message("  4. 运行项目:");
    message(&format!("     $ {}", style("npm dev").cyan()));
    message("• cli_完美谢幕!");
}
